import 'package:flutter/material.dart';

class AnimatedBuilderStudy extends StatefulWidget {
  const AnimatedBuilderStudy({Key? key}) : super(key: key);

  @override
  _AnimatedBuilderStudyState createState() => _AnimatedBuilderStudyState();
}

class _AnimatedBuilderStudyState extends State<AnimatedBuilderStudy>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this,duration: Duration(seconds: 5))..repeat();

    //Animation opAnimal = Tween(begin: 200.0,end: 300).animate(_controller);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("自定义动画学习"),
      ),
      body: Center(
        child: AnimatedBuilder(
          animation: _controller,
          builder: (context, child) {
            return Opacity(
                opacity: _controller.value,
                child: Container(
                  alignment: Alignment.center,
                  width: 300*_controller.value,
                  height: Tween(begin: 200.0,end: 300.0).evaluate(_controller),
                  color: Colors.blue,
                  child: Text("hello",style: TextStyle(fontSize: 50*_controller.value),),
                ));
          }
        ),
      ),
    );
  }
}
